#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
const int MOD = 1e9;
int a[MAXN], s[MAXN];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    a[i] = 1;
    s[i] = s[i - 1] + a[i];
  }
  for (int i = k; i <= n; i++) {
    a[i] = (s[i - 1] - s[i - 1 - k] + MOD) % MOD; //+MOD 要注意
    s[i] = (s[i - 1] + a[i]) % MOD;
  }
  cout << a[n];
  return 0;
}